import Mock from 'mockjs'
export default {
  getMenu: config => {
    const { username, password } = JSON.parse(config.body)
    // 先判断用户是否存在
    // 判断账号和密码是否对应
    if (username === 'admin' && password === 'admin') {
      return {
        code: 20000,
        data: {
          menu:[
                {
                    path: '/',
                    name: 'home',
                    label: '系统首页',
                    icon: 's-home',
                    url: 'home/index'
                },
                {
                    path: '/log', 
                    name: 'log',
                    label: '检测日志',
                    icon: 'document',
                    url: 'log/index'
                },
                {
                    path: '/user',
                    name: 'user',
                    label: '用户管理',
                    icon: 'user',
                    url: 'user/index'
                },
                {
                    path: '/white',
                    name: 'white',
                    label: '白名单管理',
                    icon: 'document-add',
                    url: 'white/index'
                },
                {
                    label: '其他',
                    icon: 's-unfold',
                    children: [
                        {
                        path: '/feedback',
                        name: 'feedback',
                        label: '反馈',
                        icon: 'setting',
                        url: 'other/feedback.vue'
                        },
                        {
                        path: '/aboutUs',
                        name: 'aboutUs',
                        label: '关于我们',
                        icon: 'setting',
                        url: 'other/aboutUs.vue'
                        }
                    ]
                }
          ],
          token: Mock.Random.guid(),
          message: '获取成功',
          isAdmin: true
        }
      }
    } else if (username === 'mount' && password === 'mount') {
      return {
        code: 20000,
        data: {
          menu:[
                {
                path: '/',
                name: 'home',
                label: '系统首页',
                icon: 's-home',
                url: 'Home/Home'
                },
                {
                path: '/log', 
                name: 'log',
                label: '检测日志',
                icon: 'document',
                url: 'LogManage/LogManage'
                },
                {
                path: '/white',
                name: 'white',
                label: '白名单管理',
                icon: 'document-add',
                url: 'WhiteManage/WhiteManage'
                },
                {
                label: '其他',
                icon: 's-unfold',
                children: [
                    {
                    path: '/feedback',
                    name: 'feedback',
                    label: '反馈',
                    icon: 'setting',
                    url: 'Other/feedback'
                    },
                    {
                    path: '/aboutUs',
                    name: 'aboutUs',
                    label: '关于我们',
                    icon: 'setting',
                    url: 'Other/aboutUs'
                    }
                ]
                }
          ],
          token: Mock.Random.guid(),
          message: '获取成功'
        }
      }
    } else {
      return {
        code: -999,
        data: {
          message: '密码错误'
        }
      }
    }

  }
}